﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChartSharp
{
    public class Legend : ChartParam
    {
        protected IEnumerable<string> _names;

        public override string Name
        {
            get { return "chdl"; }
        }

        public override string Data
        {
            get
            {
                StringBuilder builder = new StringBuilder();

                if (_names != null)
                {
                    _names.ToList().ForEach((name) =>
                    {
                        builder.Append(name);
                        builder.Append("|");
                    });

                    if (builder.Length > 0)
                    {
                        builder.Length--;
                    }
                }

                return builder.ToString();
            }
        }

        public Legend(IEnumerable<string> names)
        {
            _names = names;
        }
    }
}
